<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/jquery.easyui.min.js"></script>
    <script src="../js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="../themes/icon.css">
    <link rel="stylesheet" href="../themes/default/easyui.css">
    <link rel="stylesheet" href="../css/wu.css">
    <style type="text/css">
        .subck { display:none }/*合计单元格样式*/
        .footerbtn{position: absolute;bottom:0;width:100%;height:50px;background-color:#f1f1f1;}
        .footerbtn input{float:right;margin-right:20px;margin-top:15px;}
    </style>
    <script>
        var  selectIndex = -1;
        //关闭
        function closeLog(){
           self.parent.$("#list").dialog("close");
        }
        function reset(){
           $("#SupplierOrderList").datagrid('load',{"customName":$("#customNameshow").val()});
           document.getElementById("form1").reset()
           //$("#form1")[0].reset();
        }
        function hideTable(){
            $("#searchdiv").toggle();
        }
        function addBillCode(){
            var rows = $("#SupplierOrderList").datagrid('getSelections');
			if(rows==null){
			    alert("请选择订单！");
			    return false;
			}
            var codes=[];
            for(var i=0;i<rows.length;i++){
                codes.push(rows[i].code)
            } 
            self.parent.$("#addInstroage").datagrid('load',{"billCode":codes});
            self.parent.$("#list").dialog("close");
        }
        $(function(){
            
            //添加下拉框
            /* $('#cc').combobox({    
			    url:'/kxmanage/instroageBill/getCompanyList.json',    
			    valueField:'code',    
			    textField:'name'   
			}); */
            //数据表格
            var companyName=self.parent.$("#customName").val();
            $("#customNameshow").val(self.parent.$("#customName").val());
            $("#SupplierOrderList").datagrid({
                url:'/kxmanage/instroageBill/getSupplierOrderList.json',
                rownumbers:false,
                pageNumber:1,
                pageSize:5,
                pageList:[5,10,15],
                checkOnSelect:false,
                queryParams: {
					customName:companyName
	            },
                columns:[[
                    {field:'ck',checkbox:true},
                    {field:'code',title:'订单编号',width:140},
                    {field:'orderTime',title:'订单日期',width:140,
                        formatter:function(value,row,index){
                            return new Date(value).toLocaleDateString().replace(/\//g,'-');
                    }},
                    {field:'supplierName',title:'供应商名称',width:160},
                    {field:'amount',title:'数量',width:60},
                    {field:'money',title:'金额',width:100},
                    {field:'amount',title:'未选数量',width:60},
                    {field:'money',title:'未选金额',width:100},
                    {field:'checkStatus',title:'审核状态',
                        formatter:function(value,row,index){
                        if(row.checkStatus==1){
                            return "已审核";
                        }
                        return "未审核";
                    }}
                ]],
                toolbar:'#wu_toolbar',
                showFooter:true,
                pagination:true ,//向后台传递参数page 和rows
                onDblClickRow: function (index, row) {
                    var codes=[];
		            codes.push(row.code)
                    self.parent.$("#addInstroage").datagrid('load',{"billCode":codes});
                    self.parent.$("#list").dialog("close");
                }
            })
            
        $("#search_btn").click(function(){
            $("#SupplierOrderList").datagrid('load',serializeJson())
        }) 
        
        })
        
       //表单序列化
        function serializeJson(){  
            var serializeObj={};  
            var array=$("#form1").serializeArray();  
            var str=$("#form1").serialize();  
            $(array).each(function(){  
                if(serializeObj[this.name]){  
                    if($.isArray(serializeObj[this.name])){  
                        serializeObj[this.name].push(this.value);  
                    }else{  
                        serializeObj[this.name]=[serializeObj[this.name],this.value];
                    }  
                }else{  
                    serializeObj[this.name]=this.value;   
                }  
            });  
                return serializeObj;  
            }; 
        //指定列求和
        function compute(colName) {
            var rows = $('#productList').datagrid('getRows');
            var total = 0;
            for (var i = 0; i < rows.length; i++) {
                total += parseFloat(rows[i][colName]);
            }
            return total;
        }
      
    </script>
</head>
<body  class="easyui-layout">
<div  id="wu_toolbar">
    
    <div id="searchdiv" style="display: block;width: 100%;">
        <form name="form1" id="form1">
            <table width="100%" border="0" cellspacing="0" style="background-color:#C9DFFF;border-top:1px solid white;" >
                <tbody><tr>
                    <td width="70"><b>检索条件:</b><input type="hidden" value="" id="customNameshow" name="customName"/></td>
                    <td width="70" align="right">订单编号:</td>
                    <td width="150" align="left"><input name="code" class="easyui-textbox" type="text" id="findcode" value="" maxlength="100"></td>
                    <td width="70" align="right">开始日期:</td>
                    <td width="150" align="left"><div class="l-text-wrapper"><div class="l-text l-text-date"><input name="fromDate" type="text" id="findstartDate" value="" maxlength="30" class="easyui-datebox" ligeruiid="findstartDate"><div class="l-text-l"></div><div class="l-text-r"></div><div class="l-trigger"><div class="l-trigger-icon"></div></div></div></div></td>
                    <td width="70" align="right">结束日期:</td>
                    <td width="150" align="left"><div class="l-text-wrapper"><div class="l-text l-text-date"><input name="endDate" type="text" id="findendDate" value="" maxlength="30" class="easyui-datebox" ligeruiid="findendDate"><div class="l-text-l"></div><div class="l-text-r"></div><div class="l-trigger"><div class="l-trigger-icon"></div></div></div></div></td>
                    <td width="72">
                        <a id="search_btn" href="#" class="easyui-linkbutton" style="height:25px;" data-options="iconCls:'icon-search'">搜索</a>
                    </td>
                    <td width="72">
                        <a id="reset_btn" href="#" class="easyui-linkbutton" style="height:25px;" onclick="reset()" data-options="iconCls:'icon-refresh'">重置</a>
                    </td>
                    <td width="0"></td>
                </tr>
                </tbody>
            </table>
            <input type="hidden" id="menuCode" value="100001001">
        </form>
    </div>
</div>
<div id="SupplierOrderList" class="easyui-datagrid">

</div>
<div class="footerbtn"><input type="button" onclick="closeLog()"  value="退出"/><input type="button" onclick="addBillCode()" value="添加"/></div>
</body>
</html>